#include<stdio.h>
int main ()
{
	int n;int i;int money;int count;
	scanf("%d",&n);int j,k,l;
	for(i=0;i<n;i++)
	{
		count=0;
		scanf("%d",&money);
		for(j=1;j<=money;j++)
		{
			for(k=1;k<=money;k++)
			{
				for(l=1;l<=money;l++)
				{
					if((j*1+k*2+l*5)==money)
					{
						printf("%d %d %d\n",j,k,l);
						count++;
						
					}
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}
